package academic.concordia.bankofquebec.bean.bill;

import org.springframework.transaction.annotation.Transactional;

import academic.concordia.bankofquebec.dao.bill.IBillDAO;
import academic.concordia.bankofquebec.dao.client.IClientDAO;
import academic.concordia.bankofquebec.entity.Bill;
import academic.concordia.bankofquebec.entity.Client;

@Transactional(readOnly = true)
public class BillBean implements IBillBean {

	IBillDAO billDAO;
	
	IClientDAO clientDAO;
	
	@Override
	@Transactional(readOnly = false)
	public void createBill(Bill bill) {
		Client client = clientDAO.getClientById(bill.getClient().getIdNumber());
		client.getBills().add(bill);
		clientDAO.updateClient(client);
	}

	public IBillDAO getBillDAO() {
		return billDAO;
	}

	public void setBillDAO(IBillDAO billDAO) {
		this.billDAO = billDAO;
	}

	public IClientDAO getClientDAO() {
		return clientDAO;
	}

	public void setClientDAO(IClientDAO clientDAO) {
		this.clientDAO = clientDAO;
	}
	
}
